#include "running.h"

void Running(void)
{ 
    PID_Init();
    HALL_Init();    
   
    while (1)
    {
        pid_speed = (pid_speed > 100) ? 100 : pid_speed;
        pid_speed = (pid_speed < -100) ? -100 : pid_speed;

        Walk_go(pid_speed);    
        
    }  
}

void HALL_Init(void)
{

    __HAL_RCC_GPIOA_CLK_ENABLE(); //开启GPIOA时钟
    __HAL_RCC_GPIOE_CLK_ENABLE(); //开启GPIOE时钟
    
    HAL_TIM_Base_Start_IT(&htim3);
    HAL_TIM_Base_Start_IT(&htim6);

    HAL_TIM_Encoder_Start(&htim1, TIM_CHANNEL_ALL);
  
    HAL_TIM_PWM_Start(&htim3, TIM_CHANNEL_1);
    HAL_TIM_PWM_Start(&htim3, TIM_CHANNEL_2);
}